package com.abvnet.project.water.project.controller;

import com.abvnet.framework.aspectj.lang.annotation.Log;
import com.abvnet.framework.aspectj.lang.enums.BusinessType;
import com.abvnet.framework.web.controller.BaseController;
import com.abvnet.framework.web.domain.AjaxResult;
import com.abvnet.framework.web.page.TableDataInfo;
import com.abvnet.project.water.project.domain.ProjectCustomerEvaluate;
import com.abvnet.project.water.project.service.IProjectCustomerEvaluateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/project/projectCustomerEvaluate")
public class ProjectCustomerEvaluateController extends BaseController {
    private String prefix = "project/projectCustomerEvaluate";

    @Autowired
    private IProjectCustomerEvaluateService projectCustomerEvaluateService;

    @RequiresPermissions("project:projectCustomerEvaluate:list")
    @GetMapping()
    public String projectCustomerEvaluate()
    {
        return prefix + "/list";
    }

    /**
     * 查询客户评估列表
     */
    @RequiresPermissions("project:projectCustomerEvaluate:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProjectCustomerEvaluate projectCustomerEvaluate) {
        startPage();
        List<ProjectCustomerEvaluate> list = projectCustomerEvaluateService.selectProjectCustomerEvaluateList(projectCustomerEvaluate);
        return getDataTable(list);
    }

    /**
     * 新增客户评估
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存客户评估
     */
    @RequiresPermissions("project:projectCustomerEvaluate:add")
    @Log(title = "客户评估", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProjectCustomerEvaluate projectCustomerEvaluate) {
        return toAjax(projectCustomerEvaluateService.insertProjectCustomerEvaluate(projectCustomerEvaluate));
    }

    /**
     * 修改客户评估
     */
    @GetMapping("/edit/{evaluateId}")
    public String edit(@PathVariable("evaluateId") Long evaluateId, ModelMap mmap) {
        ProjectCustomerEvaluate projectCustomerEvaluate = projectCustomerEvaluateService.selectProjectCustomerEvaluateById(evaluateId);
        mmap.put("projectCustomerEvaluate", projectCustomerEvaluate);
        return prefix + "/edit";
    }

    /**
     * 修改保存客户评估
     */
    @RequiresPermissions("project:projectCustomerEvaluate:edit")
    @Log(title = "客户评估", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProjectCustomerEvaluate projectCustomerEvaluate) {
        return toAjax(projectCustomerEvaluateService.updateProjectCustomerEvaluate(projectCustomerEvaluate));
    }

    /**
     * 删除客户评估
     */
    @RequiresPermissions("project:projectCustomerEvaluate:remove")
    @Log(title = "客户评估", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(projectCustomerEvaluateService.deleteProjectCustomerEvaluateByIds(ids));
    }
}
